package red.ouo.distributedtools.redis.message.config;

import org.springframework.util.Assert;
import red.ouo.distributedtools.redis.message.core.RedisMessageCore;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class MessageQueueConfig implements MessageQueueConfigInterface {
    RedisMessageConfig redisMessageConfig;

    public MessageQueueConfig(RedisMessageConfig messageQueueConfig) {
        this.redisMessageConfig = messageQueueConfig;
    }

    @Override
    public MessageQueueConfig registerQueue(String queueName) {
        redisMessageConfig.registerQueue(queueName, Executors.newSingleThreadExecutor());
        return MessageQueueConfig.this;
    }

    @Override
    public MessageQueueConfig registerQueue(String queueName, ExecutorService executorService) {
        Assert.hasLength(queueName, "QueueName NOT NULL");
        redisMessageConfig.registerQueue(queueName, executorService);
        return MessageQueueConfig.this;
    }
}
